When an Agent isn't working, the "No" links to either the Agent's details tab, or its Logs tab, depending on if the most recent log is an error.

Andrew Cantino 11 年之前
父节点
当前提交
700209155a
共有 2 个文件被更改,包括 7 次插入4 次删除
  1. 6 3
      app/assets/javascripts/application.js.coffee.erb
  2. 1 1
      app/helpers/application_helper.rb

+ 6 - 3
app/assets/javascripts/application.js.coffee.erb

@@ -76,9 +76,12 @@ $(document).ready ->
76 76
         $("#logs .spinner").stop(true, true).fadeOut ->
77 77
           $("#logs .refresh, #logs .clear").show()
78 78
 
79
-  $(".agent-show #show-tabs a[href='#logs']").on "click", fetchLogs
80
-  $("#logs .refresh").on "click", fetchLogs
81
-  $("#logs .clear").on "click", clearLogs
79
+  $(".agent-show #show-tabs a[href='#logs'], #logs .refresh").on "click", fetchLogs
80
+  $(".agent-show #logs .clear").on "click", clearLogs
81
+
82
+  if tab = window.location.href.match(/tab=(\w+)\b/i)?[1]
83
+    if tab in ["details", "logs"]
84
+      $(".agent-show .nav-tabs li a[href='##{tab}']").click()
82 85
 
83 86
   # Editing Agents
84 87
   $("#agent_source_ids").on "change", showEventDescriptions

+ 1 - 1
app/helpers/application_helper.rb

@@ -11,7 +11,7 @@ module ApplicationHelper
11 11
     if agent.working?
12 12
       '<span class="label label-success">Yes</span>'.html_safe
13 13
     else
14
-      '<span class="label label-warning">No</span>'.html_safe
14
+      link_to '<span class="label label-warning">No</span>'.html_safe, agent_path(agent, :tab => (agent.recent_error_logs? ? 'logs' : 'details'))
15 15
     end
16 16
   end
17 17
 end